﻿
using Newtonsoft.Json;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Models.Common;
using Models.JsonResultModel;
using ServiceWeb.DBGateway;
using Models.Constant;
using NuGet.Configuration;
using ServiceWeb.WebAdmin;
using UtilsBase;
using UtilsORM;
using UtilsORM.MySqlData;
using GatewayServer.Common;

namespace GatewayServer.Controllers
{
    public class ProductCopyController : BaseMagerController
    {
        EFYihongIotContext ef = new EFYihongIotContext();
        // GET: Mager_Department
        public IActionResult copy(string pguid)
        {
            iot_product product = new DBIotProduct().getProduct(pguid);
            ViewBag.p_code = product.p_code;

            ViewBag.p_name = product.p_name;
            ViewBag.p_guid = pguid;
            return View();
        }
        public RespResultData saveCopy(HttpReqModel httpReqModel, iot_product reqProduct)
        {

            new ServiceProduct().copyProduct(reqProduct.p_guid, reqProduct.p_name);
            return RespResult.Sucess();
        }
        public RespResultData saveModel(iot_product_model reqModel, iot_product reqProduct)
        {
            reqModel.pm_p_guid = reqProduct.p_guid;
            new DBIotProductModel().saveAll(LoginUserInfo, reqModel);
            return RespResult.Sucess();
        }


        public RespResultData createProduct(string pmguid, string cguid)
        {
            cguid = LoginUserInfo.userCompanyGuid;
            new ServiceProduct().createProduct(pmguid, cguid);
            return RespResult.Sucess();
        }
    }
}